<?php session_start(); ?>
<?php

include "Connect.php";

$viewSum = $_POST['viewSum'];

$select = $_POST['select'];
$select2 = $_POST['select2'];
$year = $_POST['year'];


switch ($select2) {
    case "Jan":
  $ge = "01";
        break;
 case "Feb":
$ge = "02";
  break;
   case "Mar":
$ge = "03";
  break;
   case "Apr":
$ge = "04";
  break;
   case "May":
$ge = "05";
  break;
   case "Jun":
$ge = "06";
  break;
   case "Jul":
$ge = "07";
  break;
   case "Aug":
$ge = "08";
  break;
   case "Sep":
$ge = "09";
  break;
   case "Oct":
$ge = "10";
  break;
   case "Nov":
$ge = "11";
  break;
   case "Dec":
$ge = "12";
  break;

}

$posted = $select."-".$ge."-".$year;

if(isset($viewSum)){

//echo "mm";
//echo $posted;

if($select == "--Select day--" || $select2 == "--Select month--" || $year == ""){
$_SESSION['ms'] = "";
$msg = "Please provide all fields"; 
header("location:myGraph.php?poll=$msg");
}else{
$count = 0;
$query = "SELECT * FROM paidorder WHERE Date = '$posted'";
$result = mysql_query($query);
$p=0;
while($row = mysql_fetch_array($result)){
$p =$p+ $row[4];
$count++;
}
if($p==0){
$p = $p.".00 UGX";
$_SESSION['ms'] = "No sales found for ".$posted;
include "myGraph.php";
}
else{
$p = $p;
$p = $p.".00 UGX";
$_SESSION['ms'] = "Sales for ".$posted;
//header("location:myGraph.php?poll=$msg");
include "myGraph.php";
}
//
///*$g = mysql_query("SELECT * FROM paidorder WHERE Date = '$posted' ") or die(mysql_error());
//
//$cc = mysql_fetch_array($g) or die(mysql_error());
//
//$hh = mysql_num_rows($g) or die(mysql_error());
////echo $hh; 
//if($hh == 0){
//include "myGraphgggg.php";
//echo "No Results Found.";
//}
//else {
///*for($i = 0; $i<$hh; $i++){
//
//$p = 0;
//
//$p = $p + $cc['Price'];
//
//}*/
///*
//$msg = "There are no results on". $posted; 
//include "myGraph.php";
///*$msg = "There are no results on". $posted; 
//header("location:myGraph.php?poll=$msg");
//
//}else{*/
//echo "Some Results Found";
//$p = 0;
//for($i = 1; $i<=$hh; $i++){
//$r = mysql_fetch_array(mysql_query("SELECT Price FROM paidorder WHERE ID = $i "));
//
//$p = $p + $r['Price'];
//
//}
//include "myGraph.php";
//}
//   }
//
//
//  */

}
}

?>



